package com.pb.camera.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexValidateUtil {
	
    /**
     * 验证邮箱
     * @param email
     * @return
     */
    public static boolean checkEmail(String email){
        boolean flag = false;
        try{
                String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
                Pattern regex = Pattern.compile(check);
                Matcher matcher = regex.matcher(email);
                flag = matcher.matches();
            }catch(Exception e){
                flag = false;
            }
        return flag;
    }
     
    /**
     * 验证手机号码
     * @param mobiles
     * @return
     */
    public static boolean checkMobileNumber(String mobileNumber){
        boolean flag = false;
        try{
        	     Pattern regex= Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
              //  Pattern regex = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,3,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$");
                Matcher matcher = regex.matcher(mobileNumber);
                flag = matcher.matches();
            }catch(Exception e){
                flag = false;
            }
        return flag;
    }

public static boolean checkName(String name) {  
    
      //\u4E00-\u9FA5验证是不是中文的
	   boolean flag = false;
   
   try{
	//   Pattern pattern = Pattern.compile("[0-9a-zA-Z_{6,20}]+");  
	   Pattern pattern = Pattern.compile("[0-9a-zA-Z_]{6,20}");  
	    Matcher matcher = pattern.matcher(name);   
       flag = matcher.matches();
   }catch(Exception e){
       flag = false;
   }
   return flag;
    }  
public static boolean checkVerrificationCode(String verrificationCode){
    boolean flag = false;
    try{
    	     Pattern regex= Pattern.compile("^[1,2,3,4,5,6,7,8,9][0-6]$");
          //  Pattern regex = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,3,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$");
            Matcher matcher = regex.matcher(verrificationCode);
            flag = matcher.matches();
        }catch(Exception e){
            flag = false;
        }
    return flag;
}

}
